package com.eightbears.beboy.ui.user.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.eightbears.beboy.MainActivity;
import com.eightbears.beboy.R;
import com.eightbears.beboy.base.BaseActivity;
import com.eightbears.beboy.base.view.SwipeBackLayout;
import com.eightbears.beboy.entity.UserInfoEntity;
import com.eightbears.beboy.ui.user.fragment.MoneyRedFragment;
import com.eightbears.beboy.ui.user.fragment.MyClientFragment;
import com.eightbears.beboy.ui.user.fragment.PostRedFragment;
import com.eightbears.beboy.ui.user.fragment.RrofitFragment;

import butterknife.BindColor;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static com.eightbears.beboy.ui.user.activity.PaymentActivity.PARAMS_RED_TYPE;
import static com.eightbears.beboy.ui.user.fragment.MyFragment.EVENT_UPDATE_USERINFO;

/**
 * 我的客户
 */
public class MyClientActivity extends BaseActivity {


    @BindView(R.id.ll_back)
    LinearLayout mLlBack;
    @BindView(R.id.tv_tab_left_text)
    TextView mTvTabLeftText;
    @BindView(R.id.view_left_line)
    View mViewLeftLine;
    @BindView(R.id.ll_tab_left)
    LinearLayout mLlTabLeft;
    @BindView(R.id.tv_tab_right_text)
    TextView mTvTabRightText;
    @BindView(R.id.view_right_line)
    View mViewRightLine;
    @BindView(R.id.ll_tab_right)
    LinearLayout mLlTabRight;
    @BindView(R.id.rl_title_root)
    RelativeLayout mRlTitleRoot;
    @BindView(R.id.tv_save)
    TextView mTvSave;
    @BindView(R.id.frame_container)
    LinearLayout mFrameContainer;
    @BindView(R.id.activity_left_menu_collect)
    RelativeLayout mActivityLeftMenuCollect;
    @BindView(R.id.sw_shopdetail)
    SwipeBackLayout mSwShopdetail;

    @BindColor(R.color.text_color_fff)
    int select;
    @BindColor(R.color.transparent_99FFF)
    int unselect;
    @BindColor(R.color.text_select_color)
    int selectLine;
    @BindColor(R.color.transparent_00000)
    int unselectLine;



    UserInfoEntity  mUserInfoEntity;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_client);
        initView();
        initData();
        initEvent();
    }

    @Override
    protected void initView() {
        ButterKnife.bind(this);
        mTvTabLeftText.setText(R.string.text_my_client);
        mTvTabRightText.setText(R.string.text_my_profit);
        mTvSave.setVisibility(View.VISIBLE);

          mUserInfoEntity = (UserInfoEntity) getExtras().get(EVENT_UPDATE_USERINFO);
    }

    @Override
    protected void initData() {
        selectLeft();
    }

    @Override
    protected void initEvent() {
        //侧滑删除实力化
        mSwShopdetail.setCallBack(new SwipeBackLayout.CallBack() {
            @Override
            public void onFinish() {
                finish();
            }
        });
    }

    @OnClick(R.id.ll_back)
    void back() {
        finish();
    }

    @OnClick(R.id.tv_tab_left_text)
    void leftMenu() {
        selectLeft();
    }

    @OnClick(R.id.tv_tab_right_text)
    void rightMenu() {
        selectRight();

    }

    @OnClick(R.id.tv_save)
    void tv_save() {
        //推广
        startLocalActivity((Activity) mContext, InviteFriendsActivity.class);
    }

    private void selectRight() {
        replaceView();
        mTvTabRightText.setTextColor(select);
        mViewRightLine.setBackgroundResource(R.color.text_select_color);
        replaceFragment(R.id.frame_container, new RrofitFragment(),EVENT_UPDATE_USERINFO,mUserInfoEntity);
    }

    private void selectLeft() {
        replaceView();
        mTvTabLeftText.setTextColor(select);
        mViewLeftLine.setBackgroundResource(R.color.text_select_color);
        replaceFragment(R.id.frame_container, new MyClientFragment());
    }

    private void replaceView() {
        mTvTabLeftText.setTextColor(unselect);
        mTvTabRightText.setTextColor(unselect);
        mViewLeftLine.setBackgroundResource(unselectLine);
        mViewRightLine.setBackgroundResource(unselectLine);
    }
}
